{__NOLAYOUT__}
{include file='../public/header' /}
<div class="container-fluid bg-white h-100 table-responsive ">
    <br>
    <div class="row">
        <form class="m-auto w-75" id="content" action="{$Request.root}/{$Request.controller}/addPost">
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">所属课程</label>
                <div class="col-sm-10">
                    <div class="form-group">
                        <select class="custom-select select2bs4" id="courseId" onchange="getSelectChapter()" name="course_id">
                            <option value="">无</option>
                            {volist name="courselist" id="vo"}
                            <option value="{$vo.id}">{$vo.title}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">所属章节</label>
                <div class="col-sm-10">
                    <div class="form-group">
                        <select class="custom-select select2bs4" id="chapterId" name="chapter_id">
                            <option value="">无</option>
                            {volist name="chapterlist" id="vo"}
                            <option value="{$vo.id}">{$vo.title}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">视频名称</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="title" placeholder="请输入视频名称">
                </div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">视频简介</label>
                <div class="col-sm-10">
                    <textarea class="form-control" rows="3" name="description" placeholder="请输入视频简介"></textarea>
                </div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">SEO标题</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="seoTitle" placeholder="请输入SEO标题">
                </div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">SEO关键字</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="seoKeywords" placeholder="请输入SEO关键字">
                </div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">SEO描述</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="seoDescription" placeholder="请输入SEO描述">
                </div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">视频上传</label>
                <div class="col-sm-10">
                    <div class="input-group input-group-lg mb-3">
                        <div class="input-group-prepend">
                            <select class="form-control h-100" id="channel" name="channel">
                                <option value="local">本地上传</option>
                                <option value="alivod">阿里云上传</option>
                            </select>
                        </div>
                        <input type="text" class="form-control" id="video_url" name="video_url">
                        <span class="input-group-append">
                            <input type="file" name="file" id="upload_video" class="display-none" onchange="uploadVideo('video_url','upload_video','video_label')" accept="video/mp4" />
                            <label for="upload_video" id="video_label" class="btn btn-info btn-flat">
                                上传
                            </label>
                        </span>
                    </div>
                </div>
            </div>

            <div class="form-group row">
                <label class="col-sm-2 col-form-label">视频缩略图</label>
                <div class="col-sm-10">

                    <input id="img_upload" type="file" onchange="uploadImg('image_url','img_upload','preview_image','img_label')" accept="image/*" />
                    <input type="hidden" name="image_url" id="image_url" value="">
                    <div id="preview_image">
                        <img src="">
                    </div>
                    <label for="img_upload" class="btn btn-warning btn-sm mt-2" id="img_label">缩略图上传
                    </label>
                </div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">备注</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="remark" placeholder="请输入备注">
                </div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 col-form-label">显示</label>
                <div class="col-sm-10">
                    <div class="form-group">
                        <div class="icheck-success d-inline">
                            <input type="checkbox" name="show_status" value="1" checked id="showStatus">
                            <label for="showStatus">
                                是否可用
                            </label>
                        </div>
                    </div>
                </div>
            </div>
            
    <button class="sub-bindbtn" id="{:config('app.app_debug') ? 'debug':'nodebug'}" lay-submit lay-filter="bind">

            
        </form>
    </div>
</div>
{include file='../public/script' /}
<script type="text/javascript">

function getSelectChapter() {

    var courseId = $('#courseId option:selected').val();
    if (courseId) {
        $("#chapterId option:not(:first)").remove();
    }
    $.post("/vod/AdminCourseVideo/getChapterList", { course_id: courseId }, function(json) {
        $.each(json.data, function(i, item) {
            $("<option></option>").val(item["id"]).text(item["title"]).appendTo($("#chapterId"));
        });
    }, "json");

}



</script>